package com.lin.controller;


import com.lin.commons.Result;
import com.lin.dto.CarUserBillDTO;
import com.lin.entity.CarUserBill;
import com.lin.service.CarUserBillService;
import com.lin.vo.DataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 林伟鸿
 * @since 2021-11-24
 */
@RestController
@RequestMapping("/carUserBill")
@CrossOrigin
public class CarUserBillController {

    @Autowired
    CarUserBillService carUserBillService;

    @PostMapping("/rentalCar")
    public Result rentalCar(@RequestBody CarUserBillDTO carUserBillDTO) {
        int rentalCar = carUserBillService.rentalCar(carUserBillDTO);
        if (rentalCar == 1) {
            return Result.success("租车成功");
        } else {
            return Result.failure("租车失败");
        }
    }

    @GetMapping("/myRentalInfo")
    public DataVO<CarUserBill> getMyRentalInfo(Integer page, Integer limit, String userId) {
        return carUserBillService.carUserBillInformation(page, limit, userId);
    }



}

